package EmunClass;

/**
 * @author 李泽伟
 */
public class Main {
    public static void main(String[] args) {
        //1.jdk5.0之前，自定义枚举类 自己造一组常量 Season{name='春天', desc='春暖花开'}
        System.out.println(Season.SPRING);
        //2.使用enum关键字定义枚举类 Seasons{name='春天', desc='春暖花开'}
        System.out.println(Seasons.SPRING);
        System.out.println("***********");
        Seasons[] values = Seasons.values();
        for (Seasons value : values) {
            System.out.println(value);
        }
    }
}
/**
 * 自定义枚举类
 */
class Season{
    /**
     * 1.声明属性，使用private final修饰
     */
    private final String name;
    private final String desc;

    /**
     * 2.提供对象属性赋值的私有化类的构造器
     */
    private Season(String name, String desc) {
        this.name = name;
        this.desc = desc;
    }
    /**
     * 3.提供当前枚举类的多个对象 使用public static final修饰
     */
    public static final Season SPRING = new Season("春天", "春暖花开");
    public static final Season SUMMER = new Season("夏天", "夏日炎炎");
    public static final Season AUTUMN = new Season("秋天", "秋高气爽");
    public static final Season WINTER = new Season("冬天", "冰天雪地");
    public String getName() {
        return name;
    }
    public String getDesc() {
        return desc;
    }
    @Override
    public String toString() {
        return "Season{" +
                "name='" + name + '\'' +
                ", desc='" + desc + '\'' +
                '}';
    }
}

/**
 * 使用enum关键字的枚举类
 */
enum Seasons{
    /**
     * 1.提供当前枚举类的对象，多个对象之间用“,”，末尾对象使用";"结束
     */
    SPRING("春天", "春暖花开"),
    SUMMER("夏天", "夏日炎炎"),
    AUTUMN("秋天", "秋高气爽"),
    WINTER("冬天", "冰天雪地");
    /**
     * 2.声明对象的属性
     */
    private final String name;
    private final String desc;
    /**
     * 3.私有化 类的构造器，并给对象赋值
     */
    private Seasons(String name, String desc) {
        this.name = name;
        this.desc = desc;
    }
    //4.提供获取属性的方法
    public String getName() {
        return name;
    }
    public String getDesc() {
        return desc;
    }
    //5.提供toString方法
    @Override
    public String toString() {
        return "Seasons{" +
                "name='" + name + '\'' +
                ", desc='" + desc + '\'' +
                '}';
    }
}